﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using ENTITY;

namespace MODELS
{
    public class MOD_Bai
    {
        private dbConnect dbConn;
        public MOD_Bai()
        {
            dbConn = new dbConnect();
        }
        public DataTable select_STR(string strSQL)
        {
            return dbConn.GetData(strSQL);
        }
        public DataTable SelectAll()
        {
            return dbConn.GetData("Bai_SelectALL", null);
        }

        public int Insert(EN_Bai obj_En)
        {
            SqlParameter[] para = { 
                                   
                                    new SqlParameter("MaChuong",obj_En.MaChuong),
                                     new SqlParameter("Mabai",obj_En.MaBai),
                                    new SqlParameter("TenBai",obj_En.TenBai),
                                    new SqlParameter("NoiDung",obj_En.NoiDug),
                                    new SqlParameter("Video",obj_En.Video)
                                  };
            return dbConn.ExecuteSQL("Bai_insert", para);
        }

        public int Update(EN_Bai obj_En)
        {
            SqlParameter[] para = {
                                      new SqlParameter("MaChuong",obj_En.MaChuong),
                                     new SqlParameter("MaBai",obj_En.MaBai),
                                    new SqlParameter("TenBai",obj_En.TenBai),
                                    new SqlParameter("NoiDung",obj_En.NoiDug),
                                     new SqlParameter("Video",obj_En.Video)
                                  };
            return dbConn.ExecuteSQL("Bai_Update", para);
        }

        public int Delete(EN_Bai obj_En)
        {
            SqlParameter[] para = { 
                                    new SqlParameter("MaBai", obj_En.MaBai)
                                  };
            return dbConn.ExecuteSQL("Bai_Delete", para);
        }
    }
}
